package com.jh.user.repository;

import com.jh.user.pojo.StoreInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StoreInfoRepository extends JpaRepository<StoreInfo,String>,JpaSpecificationExecutor<StoreInfo> {
    StoreInfo findByStoreNo(String uuid);

    @Query("select storeInfo from StoreInfo  storeInfo where storeInfo.shopId=:shopId")
    List<StoreInfo>  findStoreByShopId(@Param("shopId")String shopId);


    List<StoreInfo> findStoreByPhoneAndShopId(String phone, String shopId);

    List<StoreInfo> findStoreByEmailAndShopId(String email, String shopId);

    @Query(value = "delete from StoreInfo storeInfo where storeInfo.shopId=:shopId and storeInfo.storeNo=:storeNo")
    @Modifying
    void deleteByShopIdAndStoreNo(@Param("shopId")String shopId,@Param("storeNo") String storeNo);

    @Query(value = "select storeInfo from StoreInfo storeInfo where storeInfo.shopId = :shopId")
    StoreInfo findByShopId(@Param("shopId") String shopId);
}
